home *** CD-ROM | disk | FTP | other *** search
/ Isometric Game Programming with DirectX 7.0 / Isometric Game Programming.iso / directx / dxf / bin / dxutil / dxtex.txt < prev    next >
Encoding:
Text File  |  2000-09-22  |  8.6 KB  |  173 lines

  1. Readme for the DirectX Texture Tool
  2.  
  3.  
  4. Purpose and Audience
  5. --------------------
  6. The purpose of this tool is to allow DirectX SDK users to easily create texture
  7. maps that use the DXTn compression formats.  Creating a DXTn-compressed
  8. texture is actually not that difficult to do: DirectDraw's Blt function can
  9. do the conversion for you.  Advanced developers will probably want to write
  10. their own tools that meet their specific needs.  But this tool provides useful
  11. basic functionality.
  12.  
  13.  
  14. DxTex Functionality
  15. -------------------
  16. Opens BMP and DDS files (See below for a description of the DDS file format)
  17. Opens BMP files as alpha channel, either explicitly or implicitly (via 
  18. foo_a.bmp naming)
  19. Saves textures in DDS format
  20. Supports conversion to all five DXTn compression formats
  21. Supports generation of mip maps (using a box filter)
  22. Supports visualization of alpha channel as a greyscale image or via a user-
  23. selectable background color
  24. Supports easy visual comparison of image quality between formats
  25.  
  26.  
  27. User Interface
  28. --------------
  29. DxTex uses a pretty traditional user interface.  Each texture map is a 
  30. document, and several documents can be open at a time.  The one thing that
  31. is a bit unusual about the UI is that each document can hold the texture
  32. in either one or two formats at once while the document is open in DxTex.
  33. For instance, one could import a BMP file, which would automatically create
  34. a 32-bit ARGB texture.  One could then choose to convert the texture to 
  35. DXT1 format.  The document now remembers the image in *both* formats, and
  36. the user can flip between the formats by clicking in the window or by 
  37. choosing "Original" and "New" in the View menu.  This makes it easy for
  38. the user to observe any artifacts introduced by image compression, and to
  39. try several different compression formats without progressive degradation
  40. of the image  For instance, if this technique were not used and the user
  41. converted an image from ARGB to DXT1, all but one bit of alpha would be lost.
  42. If the user then decided to convert to DXT2, there would still be only two
  43. alpha levels.  With DxTex's system, the second conversion is done from the
  44. original ARGB format, and the DXT2 image will contain all 16 levels of alpha
  45. supported by DXT2.  When the image is saved, the "original" format is 
  46. discarded, and only the "new" format is stored.
  47.  
  48. There are a few consequences of this system that one must remember:
  49. - If no format conversion has been requested since the document was opened,
  50.   the one format is the "original" format and that is the format in which
  51.   the image will be written when the document is saved.
  52. - If format conversion has been requested since the document was opened, the
  53.   converted format is the "new" format and that is the format in which the
  54.   image will be written when the document is saved.
  55. - If a second format conversion is requested, the "new" format from the first
  56.   conversion is replaced with the second format.  The "original" format will
  57.   be unchanged.
  58. - Generating of mip maps applies to both formats simultaneously.
  59. - If the original format has multiple mip maps, and conversion to a new format
  60.   is requested, the new format will automatically have multiple mip maps as 
  61.   well.
  62. It's not as complicated as it sounds: with time, this two-format system 
  63. becomes natural and efficient to use.
  64.  
  65.  
  66. DxTex Performance
  67. -----------------
  68. DxTex uses the Direct3D Reference Rasterizer to draw the textures, 
  69. regardless of what 3D hardware is available.  So with larger textures 
  70. (greater than 256x256), the program may be somewhat slow, depending on your 
  71. CPU speed.
  72.  
  73.  
  74. DDS File Format
  75. ---------------
  76. DxTex's native file format is called "DDS" file format, because it 
  77. encapsulates the information in a DirectDrawSurface.  It has the following 
  78. format:
  79.  
  80.     DWORD dwMagic (0x20534444, or "DDS ")
  81.     DDSURFACEDESC2 ddsd (this provides information about the surface format)
  82.     BYTE bData1[] (this is the surface data for the main surface)
  83.     [BYTE bData2[]...] (surface data for attached surfaces, if any, follow)
  84.  
  85. This format is easy to read and write, and supports features such as alpha
  86. and multiple mip levels, as well as DXTn compression.  The "Compress" sample 
  87. application on the DirectX SDK demonstrates how to properly import a DDS file.
  88.  
  89. The user should note that it is not necessary to use the DDS format in order
  90. to use DXTn-compressed textures, or vice-versa.  But the two work well 
  91. together.
  92.  
  93.  
  94. Mip Maps
  95. --------
  96. Mip mapping is a technique that improves image quality and reduces texture
  97. memory bandwidth by providing prefiltered versions of the texture image at
  98. multiple resolutions.
  99.  
  100. To generate mip maps in DxTex, the width and height of the source image must 
  101. both be powers of 2.  Choose "Generate Mip Maps" from the Format menu.  
  102. Filtering is done via a simple box filter, i.e., the four nearest pixels are
  103. averaged to produce each destination pixel.  More sophisticated filtering can
  104. be found in other image processing programs.
  105.  
  106.  
  107. Alpha
  108. -----
  109. Many texture formats include an alpha channel, which provides opacity 
  110. information at each pixel.  DxTex fully supports alpha in textures.  When
  111. importing a BMP file, if a file exists of the same size with "_a" at the end
  112. (e.g., foo.bmp and foo_a.bmp), the second file will be loaded as an alpha
  113. channel.  The blue channel of the second BMP is stored in the alpha channel.
  114. Once a document is open, the user can explicitly load a BMP file as the alpha 
  115. channel via the "Open As Alpha Channel" command on the File menu.
  116.  
  117. To view the alpha channel directly without the RGB channels, choose "Alpha
  118. Channel Only" from the View menu.  The alpha channel will appear as a 
  119. greyscale image.  Note that if no alpha channel has been loaded, the alpha
  120. channel will be 100% everywhere and the image will appear solid white when
  121. viewing "Alpha Channel Only".  To turn off "Alpha Channel Only", just choose
  122. that menu item a second time.
  123.  
  124. In the usual view, the effect of the alpha channel is visible because the 
  125. window has a solid background color which shows through the texture where the
  126. alpha channel is less than 100%.  The user can change this background color
  127. by choosing "Change Background Color" from the View menu.  This choice does
  128. not affect the texture itself or the data that is written when the file is
  129. saved.
  130.  
  131. The DXT2 and DXT4 formats use premultiplied alpha, which means that the
  132. red, green, and blue values stored in the surface are already multiplied
  133. by the corresponding alpha value.  DirectDraw cannot blit from a surface
  134. containing premultiplied alpha to one containing non-premultiplied alpha,
  135. so some DxTex operations (Open as Alpha Channel, conversion to DXT3, and
  136. conversion to DXT5) are not possible on DXT2 and DXT4 formats.  Supporting
  137. textures using these formats is difficult on Direct3D devices which do
  138. not support DXTn textures, because DirectDraw cannot handle blitting them
  139. to a traditional ARGB surface either (unless that ARGB surface uses 
  140. premultiplied alpha as well, which is rare).  So you may find it easier to
  141. use DXT3 rather than DXT2 and DXT5 rather than DXT4 when possible.
  142.  
  143.  
  144. Command-Line Options
  145. --------------------
  146. Command-line options can be used to pass input files, an output file name, and
  147. processing options to DxTex.  If an output file name is specified, the program
  148. exits automatically after writing the output file, and no user interface is 
  149. presented.
  150.  
  151. dxtex [infilename] [-a alphaname] [-m] [DXT1|DXT2|DXT3|DXT4|DXT5] [outfilename]
  152.  
  153. infilename:               The name of the file to load.  This can be a BMP or 
  154.                           DDS file.
  155.  
  156. -a alphaname:             If "-a" is specified, the next parameter is the name
  157.                           of a BMP file to load as the alpha channel.  Note:
  158.                           if no alpha filename is specified, DxTex will still
  159.                           look for a file named infilename_a.bmp and, if it 
  160.                           exists, use that as the alpha channel.
  161.  
  162. -m:                       If this option is specified, mipmaps are generated.
  163.  
  164. DXT1|DXT2|DXT3|DXT4|DXT5: Specifies compression format.  If no format is 
  165.                           specified, the image will be in ARGB-8888.
  166.  
  167. outfilename:              Specifies the name of the destination file.  If this
  168.                           is not specified, the user interface will show the 
  169.                           current file and all requested operations.  If an 
  170.                           outfilename is specified, the app will exit after 
  171.                           saving the processed file without presenting a user 
  172.                           interface.
  173.